#*******************************************************************************
#this code is protected by the GNU affero GPLv3
#author:Sylvain BERTRAND <sylvain.bertrand AT gmail dot com>
#                        <digital.ragnarok AT gmail dot com>
#*******************************************************************************
export
QUIET?=
DEBUG?=
SYSROOT?=
ARCH?=$(shell uname -m | sed -e s/i.86/x86/ -e s/parisc64/parisc/ \
-e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh.*/sh/)
ALGA_HDR?=/usr/src/linux/include

LOG_WIRE_LVL?=1
LOG_UDEV_LVL?=1
LOG_EVDEV_LVL?=1
LOG_CFG_LVL?=2
LOG_LVL?=1

BUILD_DIR?=build
BIN_DIR?=$(BUILD_DIR)/bin
OBJ_DIR?=$(BUILD_DIR)/obj
CPP_DIR?=$(BUILD_DIR)/cpp

LD:=gcc
CC:=gcc
CPP:=cpp
AS:=as

CPPFLAGS?=-Wall -Wextra -I./ -I../ -I$(ALGA_HDR)
CPPFLAGS+= $$(pkg-config --cflags-only-I libudev)
ifndef DEBUG
#-Ofast makes it crash
CFLAGS?=-Wall -Wextra -std=gnu99 -O2 -march=native -c
LDFLAGS?=-nostdlib -Wl,--strip-all,-O,10
ASFLAGS?=
else
CFLAGS?=-Wall -Wextra -std=gnu99 -ggdb3 -march=native -c
LDFLAGS?=-nostdlib
ASFLAGS?=
endif

ifdef QUIET
CPPFLAGS+= -DQUIET
endif
ifdef LOG_WIRE_LVL
CPPFLAGS+= -DLOG_WIRE_LVL=$(LOG_WIRE_LVL)
endif
ifdef LOG_UDEV_LVL
CPPFLAGS+= -DLOG_UDEV_LVL=$(LOG_UDEV_LVL)
endif
ifdef LOG_EVDEV_LVL
CPPFLAGS+= -DLOG_EVDEV_LVL=$(LOG_EVDEV_LVL)
endif
ifdef LOG_CFG_LVL
CPPFLAGS+= -DLOG_CFG_LVL=$(LOG_CFG_LVL)
endif
ifdef LOG_LVL
CPPFLAGS+= -DLOG_LVL=$(LOG_LVL)
endif
